$(function () {
    console.log("dsdf");
    $.ajax({
        url: "data/this_wrold.json",
        type: "get",
        dataType: "json",
        success: function (data) {
            // console.log(data);
            var data1 = data.data;
            // console.log(data1);
            $.each(data1, function (i, obj) {
                console.log(obj);
                var ul = $("<ul></ul>");
                $.each(obj.data, function (ii, oo) {
                    // console.log(oo);
                    if (!oo.lowPrice) {
                        console.log(oo);
                        ul.append(`
                        <li>
                            <a href="javascript:;" class="clearFloat">
                                <div class="left">
                                    <span>${ oo.start}</span>
                                    <span><b>${ oo.discount}</b> 折</span>
                                    <span class="time">截止至${ oo.over}</span>
                                    <span class="price">
                                        <span>$${ (oo.original_cost*(oo.discount/10)).toFixed(2) }</span>
                                        <small>/人起</small>
                                    </span>
                                    <span class="original_cost"><s>$${ oo.original_cost }</s></span>
                                </div>
                                <div class="right" style="background:url(${ oo.imgUrl });">
                                    <div class="xx" title="${ oo.text }">
                                        <p>${ oo.text }</p>
                                    </div>
                                </div>
                            </a>
                        </li>
                        `)
                    } else if (oo.lowPrice) {
                        ul.append(`
                        <li>
                            <a href="javascript:;" class="clearFloat">
                                <div class="left">
                                    <span>${ oo.start}</span>
                                    <div>低价保障</div>
                                    <span class="price">
                                        <span>$${ oo.original_cost}</span>
                                        <small>/人起</small>
                                    </span>
                                </div>
                                <div class="right" style="background:url(${ oo.imgUrl });">
                                    <div class="xx" title="${ oo.text }">
                                        <p>${ oo.text }</p>
                                    </div>
                                </div>
                            </a>
                        </li>
                        `)
                    }
                    
                });
                $(".this_week_contents").append(ul);
            });


            // 功能
            var index = 0;
            tab();
            function tab() {
                $(".Sale_this_week .top>.right>ul>li").eq(index).addClass("active").siblings().removeClass("active");
                $(".this_week_contents>ul").eq(index).show().siblings().hide();
            }

            // 点击
            $(".Sale_this_week .top>.right>ul>li").click(function () {
                console.log($(this).index());
                index = $(this).index();
                tab();
            });
        }
    })
})